//
//  todoView.swift
//  todoList
//
//  Created by Aoyun on 02/01/2025.
//

import SwiftUI

struct todoView: View {
    @Environment(ListViewModel.self) private var listViewModel
    let item: listModel
    var body: some View {
        HStack {
            Image(systemName: item.isDo ? "checkmark.circle" : "circle")
                .foregroundColor(item.isDo ? .green : .red)
                .onTapGesture{
                    withAnimation(.linear) {
                        listViewModel.changeIsDo(item: item)
                    }
                }
            Text(item.toDo)
            Spacer()
        }
    }
}

#Preview {
    todoView(item: listModel(toDo: "read book", isDo: false)).environment(ListViewModel())
}
